package com.example.wannerone.myapplication123;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;

import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class safeysActivity extends Activity {

    private String result;

    private Handler mHanlder = new Handler() {
        @Override
        public void handleMessage(Message message) {
            result = (String) message.obj;
            JSONObject resultJson = JSON.parseObject(result);
            String finalResult = resultJson.getString("result");
            System.out.println("结果是：" + finalResult);
            if (finalResult.equals("ok")) {
                System.out.println("登陆成功");
                //建立一个意图,参数为（当前的Activity类对象，需要开的的Activity类）
                Intent intent = new Intent(safeysActivity.this, changekeyActivity.class);
                //启动意图
                startActivity(intent);
                safeysActivity.this.finish();
            } else
                System.out.println("用户名或密码错误");
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_safeys);
        //修改密码按钮
        Button btn_modifyKey = (Button) findViewById(R.id.button15);
        //监控按钮
        Button btn_monitor = (Button) findViewById(R.id.button16);

        btn_monitor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //建立一个意图,参数为（当前的Activity类对象，需要开的的Activity类）
                Intent intent = new Intent(safeysActivity.this, MonitorActivity.class);
                //启动意图
                startActivity(intent);
                safeysActivity.this.finish();
            }
        });


        btn_modifyKey.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //建立一个意图,参数为（当前的Activity类对象，需要开的的Activity类）
                Intent intent = new Intent(safeysActivity.this, changekeyActivity.class);
                //启动意图
                startActivity(intent);
            }
        });
    }

}
